package com.leyou.item.mapper;

import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Author: taft
 * @Date: 2018-9-26 16:32
 */
public interface BrandMapper extends Mapper<Brand>,SelectByIdListMapper<Brand,Long> {

    @Insert("INSERT INTO tb_category_brand VALUES (#{cid},#{id})")
    void insertCategoryBrand(@Param("cid") Long cid,@Param("id") Long id);

    @Select("SELECT b.* from tb_brand b LEFT join tb_category_brand c ON c.brand_id = b.id where c.category_id=#{cid}")
    List<Brand> queryBrandByCategory(@Param("cid") Long cid);
}
